home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / fax / src / fax2ps / defs.h next >
C/C++ Source or Header  |  1994-08-01  |  2KB  |  85 lines

  1. #ifndef _DEFS_
  2. #define    _DEFS_
  3.  
  4. /*
  5.  * Copyright (c) 1991, 1992, 1993, 1994 by Sam Leffler.
  6.  * All rights reserved.
  7.  *
  8.  * This file is provided for unrestricted use provided that this
  9.  * legend is included on all tape media and as a part of the
  10.  * software program in whole or part.  Users may copy, modify or
  11.  * distribute this file at will.
  12.  */
  13. #include "tiffiop.h"
  14.  
  15. #ifndef TRUE
  16. #define    TRUE    1
  17. #define    FALSE    0
  18. #endif
  19.  
  20. typedef    struct {
  21.     unsigned short count;    /* frequency count (maybe long?) */
  22.     unsigned short code;    /* assigned code */
  23.     unsigned long cost;        /* cost to use w/o encoding */
  24. } Code;
  25.  
  26. typedef struct {
  27.     Code    c;
  28.     unsigned short move;    /* relative move before */
  29.     unsigned short runlen;    /* runlen draw */
  30. } CodeEntry;
  31. #define    CODEHASH    8209
  32. #define    HASHCODE(x,y)    ((u_int)(((x)<<16)|(y)) % CODEHASH)
  33. extern    CodeEntry* codehash[CODEHASH];
  34. #define    MAXCODES    6000    /* about 75% population */
  35. extern    CodeEntry* codetable;
  36.  
  37. typedef struct {
  38.     Code    c;
  39.     CodeEntry*    a;        /* first part of pair */
  40.     CodeEntry*    b;        /* second part of pair */
  41. } CodePairEntry;
  42. #define    PAIRHASH    16033
  43. #define    HASHPAIR(a,b)    ((((u_int)(a)<<16)|((u_int)(b)&0xffff)) % PAIRHASH)
  44. extern    CodePairEntry* pairhash[PAIRHASH];
  45. extern    CodePairEntry* pairtable;
  46. #define    MAXPAIRS    10000
  47. extern    int maxpairs;
  48. #define    isPair(p) \
  49.     (&pairtable[0] <= (CodePairEntry*)(p) && \
  50.      (CodePairEntry*)(p) < &pairtable[maxpairs])
  51.  
  52. extern    char** codeNames;    /* codeNames[code] => ASCII code name */
  53. extern    char* codeNameSpace;    /* storage space for codeNames and strings */
  54. extern    int ncodes;        /* number of assigned codes */
  55. extern    int includeStatistics;    /* if 1, add comments w/ frequency stats */
  56. extern    int startOfRow;        /* if 1, have yet to emit a code for this row */
  57. extern    int dopairs;        /* if 1, encode pairs of codes */
  58. extern    int debug;        /* debug decoding */
  59.  
  60. extern    CodeEntry* enterCode(int dx, int len);
  61. extern    CodePairEntry* findPair(CodeEntry* a, CodeEntry* b);
  62. extern    CodePairEntry* enterPair(CodeEntry* a, CodeEntry* b);
  63. extern    int printPair(TIFF* tif, CodeEntry* a, CodeEntry* b);
  64.  
  65. #include "tif_fax3.h"
  66.  
  67. typedef struct {
  68.     long    row;
  69.     int        cc;
  70.     u_char*    buf;
  71.     u_char*    bp;
  72.     u_char*    scanline;
  73.     u_char    pass;
  74.     u_char    is2d;
  75.     u_short    options;
  76.     CodeEntry*    lastCode;
  77.     Fax3BaseState b;
  78. } Fax3DecodeState;
  79. extern    Fax3DecodeState fax;
  80.  
  81. extern    int FaxPreDecode(TIFF* tif);
  82. extern    int Fax3DecodeRow(TIFF* tif, int npels);
  83. extern    int Fax4DecodeRow(TIFF* tif, int npels);
  84. #endif    /* _DEFS_ */
  85.